import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

export default new Router({
  // mode:"history",   //路径去掉#
  routes: [
    //路由重定向
    {
      path: "/",
      redirect: "/loginIndex"
    },
    //登陆主页面
    {
      path: "/loginIndex",
      name: "/loginIndex",
      component: r => require.ensure([], () => r(require('@/views/loginIndex')), 'demo'),
      children: [
        //登陆
        {
          path: "/login",
          name: "/login",
          component: r => require.ensure([], () => r(require('@/views/login')), 'demo'),
        },
        //注册页面
        {
          path: "/register",
          name: "/register",
          component: r => require.ensure([], () => r(require('@/views/register')), 'demo'),
        },
        //路由重定向
        {
          path:"/loginIndex",
          require:"/login"
        }
      ]
    },
    //搜索页面
    {
      path: "/searchList",
      name: "/searchList",
      component: r => require.ensure([], () => r(require('@/views/searchList')), 'demo'),
    },
    //详情页面
    {
      path: "/detail",
      name: "/detail",
      component: r => require.ensure([], () => r(require('@/components/detail')), 'demo'),
    },

    //主页面
    {
      path: "/index",
      name: "/index",
      component: r => require.ensure([], () => r(require('@/views/index')), 'demo'),
      children: [
        {
          path: "/home",
          name: "/home",
          component: r => require.ensure([], () => r(require('@/views/home')), 'demo'),
        },
        {
          path: "/shop",
          name: "/shop",
          component: r => require.ensure([], () => r(require('@/views/shop')), 'demo'),
        },
        {
          path: "/cart",
          name: "/cart",
          component: r => require.ensure([], () => r(require('@/views/cart')), 'demo'),
          meta: {
            requiresAuth: true
          }
        },
        {
          path: "/user",
          name: "/user",
          component: r => require.ensure([], () => r(require('@/views/user')), 'demo'),
          meta: {
            requiresAuth: true
          }
        },
      ]
    },


  ]
})
